package com.lyh.handler;

import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.TypeHandler;

import com.lyh.model.LogTypeEnum;

public class LogTypeHandler implements TypeHandler<LogTypeEnum> {

	public LogTypeEnum getResult(ResultSet rs, String cloumnName)
			throws SQLException {
		return LogTypeEnum.codeOf(rs.getInt(cloumnName));
	}

	public LogTypeEnum getResult(ResultSet rs, int cloumnIndex) throws SQLException {
		return LogTypeEnum.codeOf(rs.getInt(cloumnIndex));
	}

	public LogTypeEnum getResult(CallableStatement cs, int cloumnIndex)
			throws SQLException {
		return LogTypeEnum.codeOf(cs.getInt(cloumnIndex));
	}

	public void setParameter(PreparedStatement pre, int i,
			LogTypeEnum parameter, JdbcType arg3) throws SQLException {
		pre.setInt(i,parameter.getCode());
	}

}
